<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>管理员列表</title>
	<hdjs />
	
	<css file='__PUBLIC__/Css/mod.base.css' />
</head>
<body>
	
	<div class="wrap">
		<form action="{:U('Admin/update')}" method="post" class='hd-form'>
				<div class="menu_list">
					<ul>
						<li>
							<a href="javascript:;" class="action">
								管理员列表
							</a>
						</li>
						<li>
							<a href="{:U('Admin/add')}">
								添加管理员
							</a>
						</li>
						
					</ul>
				</div>
				<table class="table2">
					<thead>
						<tr>
							<td class="w30">
							<input type="checkbox" class="select_all"/>
							</td>
							<td class="w30">UID</td>
							<td>用户名</td>
							<td class="w100">登录IP</td>
							<td class="w100">登录时间</td>
							<td class="w100">昵称</td>
							<td class="w100">邮箱</td>
							<td class="w100">状态</td>
							<td class="w180">操作</td>
						</tr>
					</thead>
						<if condition='$data'>
						<foreach name='data' item='v'>
						<tr>
							<td>
							<if condition="$v['uid'] neq 1">
							<input type="checkbox" name="uid[{$v.uid}]" value="{$v.uid}"/>
							</if>
							</td>
							<td>{$v.uid}</td>
							<td>{$v.username}</td>
							<td>{$v.login_ip}</td>
							<td>{$v.login_time}</td>
							<td>{$v.nickname}</td>
							<td>{$v.email}</td>
							<td>{$v.lock}</td>
							<td>
							<if condition="$v['uid'] neq 1">
							<a href="{:U('Admin/edit',array('uid'=>$v['uid']))}">
								修改
							</a>
								<span class="line">|</span>
							<a href="javascript:var del='{:U('Admin/del',array('uid'=>$v['uid']))}';hd_confirm('确认删除吗？',function(){location.href=del})">
								删除
							</a>
							</if>

							</td>
						</tr>
						</foreach>
						<tr><td colspan="9" class="page">{$page}</td></tr>
						<else/>
							<tr><td colspan="9">没有找到符合的记录</td></tr>
						</if>
					</table>
				<div class="h60"></div>
		</form>
	</div>
<div class="position-bottom">
	<input type="button" class="hd-cancel" onclick="select_all(1)" value='全选'/>
	<input type="button" class="hd-cancel" onclick="select_all(0)" value='反选'/>
	<input type="button" class="hd-cancel" onclick="update(1)" value="锁定"/>	
	<input type="button" class="hd-cancel" onclick="update(2)" value="解锁"/>	
	<input type="button" class="hd-cancel" onclick="update(3)" value="删除"/>
</div>
<script>
//更新排序
function update(type) {

	var html;
    switch(parseInt(type))
	{
		case 1:
		type='锁定';
		html='<input type="hidden" name="lock" />';
		break;
		case 2:type='解锁';
		html='<input type="hidden" name="cancel_lock" />';
		break;
		case 3:type='删除';
		html='<input type="hidden" name="del" />';
		break;
	}
    //管理员检测
    if ($("input[type='checkbox']:checked").length == 0) {
        alert('没有管理员用于'+type);
        return false;
    }
    $('form').append(html);
  	$('form').submit();
}
//点击input表单实现 全选或反选
$(function () {
    //全选
    $("input.select_all").click(function () {
        $("[type='checkbox']").attr("checked",$(this).attr('checked')=='checked');
    })
})
//全选复选框
function select_all(state){
	if(state==1){
		$("[type='checkbox']").attr("checked",state);
	}else{
		$("[type='checkbox']").attr("checked",function(){return !$(this).attr('checked')});
	}
}

</script>
</body>
</html>